<?php 
$val1 = $_POST["val1"] ;
$val2 =$_POST["val2"] ;
$calc =$_POST["calc"] ;

if (empty($val1) || empty($val2) || empty($calc)) {
	die("error");
  } 
if (strcmp($calc, "add")==0) {
      $result = $val1 + $val2;
}
else if (strcmp($calc, "minus")==0) {
      $result = $val1 - $val2;
}
else if (strcmp($calc, "multiply")==0) {
      $result = $val1 * $val2;
} 
else if (strcmp($calc, "divide")==0) {
    if($val2 ===0){
        die("Division by zero");
    }
      $result = $val1 / $val2;
}

header('Content-type: text/html; charset=utf-8');
echo "Результат равен $result";

//header("Location: http://localhost/SVN_lab5/");

echo "<br><a href='http://localhost/SVN_lab5/'>Назад</a>";

